package com.wxl.www.wxl.shiro.utils.AOP.impl.login;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

/**
 * @ClassName TokenAspect
 * @Description LoginUser校验自定义注解
 * @Author wangjian
 * @Date 19/06/25 13:29
 * @Version <1.0>
 */
@Aspect
@Component
@SuppressWarnings({"unused"})
public class LoginUser {

    @Pointcut("@annotation(com.wxl.www.wxl.shiro.utils.AOP.LoginUser)")
    public void annotationPointcut() {

    }

    @Before(value = "@annotation(com.wxl.www.wxl.shiro.utils.AOP.LoginUser)")
    public void beforePointcut(JoinPoint joinPoint) {
        // 此处进入到方法前  可以实现一些业务逻辑
//        System.out.println("656456456");
    }

    @Around("annotationPointcut()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        String[] params = methodSignature.getParameterNames();// 获取参数名称
        Object[] args = joinPoint.getArgs();// 获取参数值
        System.out.println(params.toString());
        return joinPoint.proceed();
    }

    /**
     * 在切入点return内容之后切入内容（可以用来对处理返回值做一些加工处理）
     * @param joinPoint
     */
    @AfterReturning("annotationPointcut()")
    public void doAfterReturning(JoinPoint joinPoint) {
    }
}
